/*
 * Miya.com Inc.
 * Copyright (c) 2004-2018 All Rights Reserved.
 */
package com.miya.erpmofa.common.lang.enums;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang.StringUtils;

/**
 * 商品类别枚举类
 *
 * @author zhaowei
 * @version $Id: CommodityTypeEnum.java, v 0.1 2018年01月02日 20:26 PM
 */
@SuppressWarnings("unused")
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public enum CommodityTypeEnum {

    NORMAL_TEMP("NORMAL_TEMP", "NORMAL_TEMP", "常温普通商品", "常温普通商品"),

    FREEZING("FREEZING", "FREEZING", "冷冻商品", "冷冻商品"),

    REFRIGERATE("REFRIGERATE", "REFRIGERATE", "冷藏商品", "冷藏商品"),

    LIVING("LIVING", "LIVING", "活鱼虾蟹", "活鱼虾蟹"),

    FRESH_MEAT("FRESH_MEAT", "FRESH_MEAT", "鲜肉类", "鲜肉类"),

    FRUIT_VEGETABLE("FRUIT_VEGETABLE", "FRUIT_VEGETABLE", "鲜果蔬", "鲜果蔬"),

    FLOWER("FLOWER", "FLOWER", "鲜花礼品", "鲜花礼品"),

    COLD_TO_EAT("COLD_TO_EAT", "COLD_TO_EAT", "冷食即食", "冷食即食"),

    HOT_TO_EAT("HOT_TO_EAT", "HOT_TO_EAT", "热食即食", "热食即食"),;

    /**
     * 枚举编码
     */
    @Getter
    private final String code;

    /**
     * 英文名
     */
    @Getter
    private final String englishName;

    /**
     * 中文名
     */
    @Getter
    private final String chineseName;

    /**
     * 枚举描述信息
     */
    @Getter
    private final String description;

    /**
     * 根据编码查询枚举。
     *
     * @param code 编码。
     * @return 枚举。
     */
    public static CommodityTypeEnum getByCode(String code) {
        for (CommodityTypeEnum value : CommodityTypeEnum.values()) {
            if (StringUtils.equals(code, value.getCode())) {
                return value;
            }
        }
        return null;
    }
}
